package manong.mapper;

import manong.beans.Semester;
import manong.beans.SemesterQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
@Mapper
public interface SemesterMapper {
   
    long countByExample(SemesterQuery example);

 
    int deleteByExample(SemesterQuery example);

   
    @Delete({
        "delete from semester",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into semester (`year`, semester, ",
        "week_count, statu, ",
        "mark)",
        "values (#{year,jdbcType=VARCHAR}, #{semester,jdbcType=VARCHAR}, ",
        "#{weekCount,jdbcType=INTEGER}, #{statu,jdbcType=INTEGER}, ",
        "#{mark,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(Semester record);

  
    int insertSelective(Semester record);

    List<Semester> selectByExampleWithRowbounds(SemesterQuery example, RowBounds rowBounds);

    Semester selectOneByExample(SemesterQuery example);

    List<Semester> selectByExample(SemesterQuery example);

    @Select({
        "select",
        "id, `year`, semester, week_count, statu, mark",
        "from semester",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("manong.mapper.SemesterMapper.BaseResultMap")
    Semester selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Semester record, @Param("example") SemesterQuery example);


    int updateByExample(@Param("record") Semester record, @Param("example") SemesterQuery example);

 
    int updateByPrimaryKeySelective(Semester record);

    @Update({
        "update semester",
        "set `year` = #{year,jdbcType=VARCHAR},",
          "semester = #{semester,jdbcType=VARCHAR},",
          "week_count = #{weekCount,jdbcType=INTEGER},",
          "statu = #{statu,jdbcType=INTEGER},",
          "mark = #{mark,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Semester record);

    int insertOrUpdate(Semester record);

 
    int insertOrUpdateSelective(Semester record);


    int batchInsert(@Param("list") List<Semester> list);

 
    int batchInsertSelective(@Param("list") List<Semester> list, @Param("selective") Semester.Column ... selective);
}